/*
Copyright (c) 2020 IanTang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#ifndef __DISPLAY_H
#define __DISPLAY_H

#include "main.h"

/* Private typedef -----------------------------------------------------------*/
typedef enum
{
  Display_Run,
  Display_Menu,
}Display_Status_t;

typedef struct display
{
    uint8_t task;
    /* soldering station info */
    uint16_t Iron_Temp;
    uint16_t Iron_Temp_Set;
    uint16_t Iron_Power;
    /*DC Power Source information */
    uint16_t Vol_Out;
    uint16_t Vol_Out_Set;
    uint16_t Cur_Out;
    uint16_t Cur_Out_Set;

    /* data */
}Display_t;
typedef struct menu
{
    Display_Status_t status;
    uint8_t level;
    uint8_t line;
    char table[3][8];
}Menu_t;

/* Private define ------------------------------------------------------------*/
#define EN9016_EN()       LL_GPIO_SetOutputPin(EN_9016_GPIO_Port, EN_9016_Pin)
#define EN9016_DIS()      LL_GPIO_ResetOutputPin(EN_9016_GPIO_Port, EN_9016_Pin)
#define VFD_RST_SET()     LL_GPIO_SetOutputPin(VFD_RST_GPIO_Port, VFD_RST_Pin)
#define VFD_RST_RESET()   LL_GPIO_ResetOutputPin(VFD_RST_GPIO_Port, VFD_RST_Pin)
#define VFD_CS_SET()      LL_GPIO_SetOutputPin(VFD_CS_GPIO_Port, VFD_CS_Pin)
#define VFD_CS_RESET()    LL_GPIO_ResetOutputPin(VFD_CS_GPIO_Port, VFD_CS_Pin)

/* Private macro -------------------------------------------------------------*/

/* global function ---------------------------------------------------------*/
uint8_t display_init( void );
uint8_t display_task(Display_t *display_data, Menu_t *menu, uint8_t key_value);

uint8_t display_test( void );

#endif  /* __DISPLAY_H */